<template>
  <div
    class="bts"
    v-if="dataShow.length > 0"
    :style="{
      paddingBottom: tempData.paddingBottom + 'px',
      paddingLeft: tempData.paddingTwice + 'px',
      paddingRight: tempData.paddingTwice + 'px',
      paddingTop: tempData.paddingTop + 'px',
      boxSizing: 'border-box',
      background: tempData.bgColor,
    }"
  >
    <div
      class="buttons"
      v-for="(item, index) in tempData.btnList"
      :key="index"
      v-show="item.status == 0 && tempData.btnType == 'dot'"
    >
      <div class="tags" v-show="item.tag" :style="{ background: item.tagBg, color: item.tagColor }">
        {{ item.tagText }}
      </div>
      <span class="items">
        <img :src="item.name == '首页' ? item.image2 : item.image1" alt="" />
        <p :class="[item.name == '首页' ? 'textsActive' : 'texts']">{{ item.name }}</p>
      </span>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { watch, ref } from 'vue'
  const props = defineProps({
    // 选中的当前组件参数
    compObj: {
      type: Object,
      default: () => {
        return {}
      },
    },
  })
  const tempData: any = ref({})
  const dataShow: any = ref([])
  watch(
    () => props.compObj,
    (newVal, oldVal) => {
      tempData.value = JSON.parse(JSON.stringify(newVal))
      dataShow.value = newVal.btnList.filter((item: any) => item.status == 0)
      console.log('筛选查看', dataShow.value)
      // return a
    },
    { immediate: true, deep: true }
  )
</script>

<style scoped lang="less">
  .bts {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    position: absolute;
    bottom: 0px;
    left: 0px;
    right: 0px;
    z-index: 100;
  }
  .buttons {
    width: auto;
    position: relative;
    .tags {
      width: auto;
      border-radius: 6px;
      font-size: 10px;
      line-height: 12px;
      padding: 2px 4px;
      box-sizing: border-box;
      text-align: center;
      position: absolute;
      top: 0px;
      right: 10px;
    }
    .items {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      .texts {
        width: 100%;
        text-align: center;
        color: #303133;
        font-size: 12px;
      }
      .textsActive {
        width: 100%;
        text-align: center;
        color: #409eff;
        font-size: 12px;
      }
      img {
        width: 25px;
        height: 25px;
      }
    }
  }
</style>
